/**
 * 设置登录密码的逻辑
 */
var first = true;

function SettingThePaymentPassword() {
	//$(".weui-btn").attr("disabled", false);
	if($("#password").val().trim() == '') {
		$.toast("请输入正确的旧密码!", "text");
		return false;
	}
	if($("#newpassword").val().trim() == '') {
		$.toast("登录密码不能为空!", "text");
		return false;
	}
	if($("#repassword").val().trim() == '') {
		$.toast("确认登录密码不能为空!", "text");
		return false;
	}
	if($("#newpassword").val().trim() != $("#repassword").val().trim()) {
		$.toast("两次密码不一致，请检查!", "text");
		return false;
	}
	var SettingThePaymentPasswordReqbody = {
		"newpassword": $("#newpassword").val().trim(),
		"repassword": $("#repassword").val().trim(),
		"password": $("#password").val().trim()
	};
	if(first) {
		first = false;
		$.ajax({
			type: "POST",
			url: ip + "platform/user/serverUpdateUserPassword.m",
			xhrFields: {
				withCredentials: true
			},
			crossDomain: true,
			data: SettingThePaymentPasswordReqbody,
			success: function(data) {
				if(data.statusCode == 0) {
					//$(".weui-btn").attr("disabled", true);
					$.toptip("修改登录密码成功！", 'success');
					setTimeout(function(){
				        mui.openWindow({
							createNew:true,// 打开并且刷新：true刷新，false不刷新
							show:{
								autoShow:true,
								aniShow:'fade-in',
							},
							url: 'signIn.html',
							id: 'signIn'
						});
				    },1000);
				} else if(data.statusCode == 1000) {
					loginError();
				} else {
					$.toptip(data.resultDesc, 'error');
					first = true;
				}
			}
		});
	}
}